package com.csxh.eshop.bean;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

@Entity(name="tb_course")
public class Course implements Serializable {

	private Integer id;
	private String name;
	private Set<Student> studentSet=new HashSet<Student>();
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(length=20,nullable=false,unique=true)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@ManyToMany(mappedBy="courseSet",cascade={CascadeType.REFRESH,CascadeType.MERGE})
	public Set<Student> getStudentSet() {
		return studentSet;
	}
	
	public void setStudentSet(Set<Student> studentSet) {
		this.studentSet = studentSet;
	}
	
}
